package com.pkk.cloud.support.gataway.spring.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;

/**
 * @description: jwt的检测过滤器
 * @author: peikunkun
 * @create: 2019-08-08 10:02
 **/
@Slf4j
//@Component
public class JwtCheckGatewayFilterFactory extends AbstractGatewayFilterFactory<Object> {

  /**
   * @Description: jwt的一些权限的过滤
   * @Param: [config]
   * @return: org.springframework.cloud.gateway.filter.GatewayFilter
   * @Author: peikunkun
   * @Date: 2019/8/8 0008 上午 10:04
   */
  @Override
  public GatewayFilter apply(Object config) {
    return (exchange, chain) -> {
      String jwtToken = exchange.getRequest().getHeaders().getFirst("token");
      log.info("经过了jwt过滤器:token:{}", jwtToken);
      return chain.filter(exchange);
    };
  }
}
